<!-- 标记分组 -->

<template>
  <div class="MapLabel-MapView-group Secure-MapView-point-add" :class="pointClass" :style="pointStyle">
    <div class="Secure-MapView-point-icon" :style="iconStyle" @click.stop="toEdit">
      <div class="flexCC flexCol" :style="`background: ${iconColor}`">
        <div>{{ nameTop || '-' }}</div>
        <div v-if="nameBottom">{{ nameBottom }}</div>
      </div>
    </div>
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import ViewPoint from '@admin/views/Secure/mixMap/MapView/ViewPoint'

// ============================== 导出组件 ============================== //

export default CORE.extend(ViewPoint, {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MarkGroup',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb('map', 'map_'), CORE.mixSelect('group', 'group_')],

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: {
    ...ViewPoint.computed,

    /**
     * 图标颜色
     */
    iconColor() {
      const { obj: { labelGroupId }, group_selectDict } = this
      return CORE.dict(group_selectDict, labelGroupId, 2)
    },

    /**
     * 名称上一行
     */
    nameTop() {
      const { obj: { labelGroupName: name } } = this
      return name.length < 3 ? name : name.slice(0, 2)
    },

    /**
     * 名称下一行
     */
    nameBottom() {
      const { obj: { labelGroupName: name } } = this
      return name.length < 3 ? '' : name.slice(2)
    },
  },
})
</script>
